
enum CodeEnum {none,normal,debug,error,c2s,s2c,s2s,s2w,w2s,c2w,w2c}
enum ModeEnum {none,loginModule,lobbyModule}

//数值太大 使用字符串
export default class O{
    
    public static readonly regionCode:number =  100000000
    public static readonly moduleCode:number =  10000
    //编码类型
    public static readonly SType:string[] = [
        "err",
        "c2s",
        "s2c",
        "s2s",
        "s2w",
        "w2s",
    ]

    //功能模块
    public static readonly SDeve:string[] = [
        "login",
    ]


    public static type(ierr:GLuint64):GLuint64{
        return Math.floor(ierr / O.regionCode)
    }

    public static mode(ierr:GLuint64):GLuint{
        return Math.floor((ierr % O.regionCode) / O.moduleCode)
    }

    public static code(ierr:GLuint64):GLuint{
        return Math.floor(ierr % O.moduleCode)
    }

    public static make(type:CodeEnum,mode:ModeEnum,code:GLuint):GLuint{
        return type*O.regionCode + mode*O.moduleCode + code
    }


    public static desc(ierr:GLuint64):string{
        let imark:GLuint = O.type(ierr)
        let imode:GLuint = O.mode(ierr)
        let icode:GLuint = O.code(ierr)
        let sdebg:string = O.SType[imark-1]
        return `
        ->${sdebg}
        ->mode->${imode}
        ->ICode.new(${imode})
        ->icode:${sdebg}(${icode})`
    }

}